package com.sqx.modules.disease.controller;


import com.sqx.modules.disease.entity.Prescript;
import com.sqx.modules.disease.entity.PrescriptMaterials;
import com.sqx.modules.disease.service.PrescriptMaterialsService;
import com.sqx.modules.disease.service.PrescriptService;
import com.sqx.modules.disease.utils.ChangLiangChi;
import com.sqx.modules.disease.utils.ResponseData;
import com.sqx.modules.disease.vo.DiseaseVO;
import com.sqx.modules.disease.vo.MapDataVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 药方明细表(PrescriptMaterials)表控制层
 *
 * @author makejava
 * @since 2023-11-20 21:53:25
 */
@RestController
@RequestMapping("prescriptMaterials")
@Slf4j
public class PrescriptMaterialsController {
    /**
     * 服务对象
     */
    @Resource
    private PrescriptMaterialsService prescriptMaterialsService;
    @Resource
    private PrescriptService prescriptService;


    /**
     * 处方生成
     *
     * @param diseaseVO
     * @return 处方生成
     */
    @PostMapping("/prescriptionGeneration")
    public ResponseData prescriptionGeneration(@RequestBody DiseaseVO diseaseVO) {
        return  prescriptMaterialsService.prescriptionGeneration(diseaseVO);
    }


    /**
     * 字典数据
     *
     * @return 字典数据
     */
    @PostMapping("/getDataMap")
    public ResponseData<Map<String, List<MapDataVO>>> getDataMap() {
        log.info("字典数据获取");
        Map<String, List<MapDataVO>> dataMap = ChangLiangChi.DATA_MAP;
  /*      List<Prescript> list = prescriptService.list();
        if (null != list && list.size() > 0) {
            dataMap.put("Prescript_list", list.stream().map(a -> {
                MapDataVO mapDataVO = new MapDataVO();
                mapDataVO.setValue(a.getPrescriptId() + "");
                mapDataVO.setLabel(a.getPrescriptName() + "");
                return mapDataVO;
            }).collect(Collectors.toList()));
        }*/
        return new ResponseData<Map<String, List<MapDataVO>>>().setData(dataMap).ok();
    }


}

